package com.eric.controller;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.annotation.SaCheckRole;
import cn.dev33.satoken.annotation.SaMode;
import cn.dev33.satoken.util.SaResult;
import com.eric.domain.dto.WarehouseInfoDto;
import com.eric.service.IWarehouseinfoService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;


/**
 * <p>
 * 仓库信息表 前端控制器
 * </p>
 *
 * @author 新哥
 * @since 2024-03-12
 */
@RestController
@RequestMapping("/warehouseInfo")
@RequiredArgsConstructor
public class WarehouseinfoController {
    private final IWarehouseinfoService warehouseinfoService;

//    增加仓库信息
    @PostMapping("/saveOne")
    @SaCheckRole(value = {"sys:coder","sys:superAdmin","sys:admin"},mode = SaMode.OR)
    public SaResult saveOneWarehouseInfo(@RequestBody WarehouseInfoDto warehouseinfoDto){
        return warehouseinfoService.saveOneWarehouseInfoService(warehouseinfoDto);
    }


//    删除仓库信息
    @DeleteMapping("/{id}")
    @SaCheckPermission("sys:delete")
    @SaCheckRole(value = {"sys:coder","sys:superAdmin","sys:admin"},mode = SaMode.OR)
    public SaResult deleteOneWarehouseInfo(@PathVariable("id") Integer id){
        return warehouseinfoService.deleteOneWarehouseInfoService(id);
    }

//    修改一条仓库信息
    @PutMapping("/modifyOne")
    @SaCheckPermission("sys:modify")
    @SaCheckRole(value = {"sys:coder","sys:superAdmin","sys:admin"},mode = SaMode.OR)
    public SaResult modifyOneWarehouseInfo(@RequestBody WarehouseInfoDto warehouseinfoDto ){
        return warehouseinfoService.modifyOneWarehouseInfoService(warehouseinfoDto);
    }

//    查询所有仓库
    @GetMapping("/all")
    public SaResult getAllWarehouseInfo(Integer pageCount,Integer pageSize){
        return warehouseinfoService.getAllWarehouseInfoListService(pageCount,pageSize);
    }

//    根据Id查询仓库
    @GetMapping("/{id}")
    public SaResult getOneWarehouseInfo(@PathVariable("id") Integer id){
        return warehouseinfoService.getOneWarehouseInfoListService(id);
    }

//    根据仓库名称查询仓库
    @GetMapping("/getAllByName")
    public SaResult getAllByName(String name){
        return warehouseinfoService.getAllByNameService(name);
    }
//    根据联系人查询仓库
    @GetMapping("/getAllByContact")
    public SaResult getAllByContact(String contact){
        return warehouseinfoService.getAllByContactService(contact);
    }
//    根据地址查询仓库
    @GetMapping("/getAllByAddress")
    public SaResult getAllByAddress(String address){
        return warehouseinfoService.getAllByAddressService(address);
    }




}
